<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>

    <!-- start: Meta -->
    <base href="">
    <meta charset="utf-8">
    <title>gm</title>
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="keyword" content="">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <!-- end: Meta -->

    <!-- start: Mobile Specific -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- end: Mobile Specific -->

    <!-- start: CSS -->
    <link id="bootstrap-style" href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/bootstrap-responsive.min.css" rel="stylesheet">
    <link id="base-style" href="../css/style.css" rel="stylesheet">
    <link id="base-style-responsive" href="../css/style-responsive.css" rel="stylesheet">


    <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <link id="ie-style" href="../css/ie.css" rel="stylesheet">
    <![endif]-->

    <!--[if IE 9]>
    <link id="ie9style" href="../css/ie9.css" rel="stylesheet">
    <![endif]-->

    <!-- start: Favicon -->
    <link rel="shortcut icon" href="../img/favicon.ico">
    <!-- end: Favicon -->

</head>

<body> <div class="row-fluid sortable">
    <div class="box span12">
        <div class="box-header" data-original-title>
            <h2>
                <i class="halflings-icon white edit"></i>
                <span class="break"></span>添加卡片类型
            </h2>
            <div class="box-icon">
                <a href="#" class="btn-setting">
                    <i class="halflings-icon white wrench"></i>
                </a>
                <a href="#" class="btn-minimize">
                    <i class="halflings-icon white chevron-up"></i>
                </a>
                <a href="#" class="btn-close">
                    <i class="halflings-icon white remove"></i>
                </a>
            </div>
        </div>
        <div class="box-content">
            <form class="form-horizontal" id="addForm" action="../cardType/addCardType.do" method="POST">
                <fieldset>
                    <label class="control-label" for="name">名称</label>
                    <div class="form-group controls" style="width: 446px;" title="名称">
                        <input type="text" class="form-control" name="name" id="name" placeholder="招商银行XXXX信用卡">
                    </div>

                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">保存</button>
                        <button type="reset" class="btn" onClick="javascript:location.href='../cardType/cardTypeList.web'">返回</button>

                    </div>
                </fieldset>
            </form>
        </div>
    </div><!--/span-->

</div><!--/row-->

<!-- start: JavaScript-->

<script src="../js/jquery-1.9.1.min.js"></script>
<script src="../js/jquery-migrate-1.0.0.min.js"></script>

<script src="../js/jquery-ui-1.10.0.custom.min.js"></script>

<script src="../js/jquery.ui.touch-punch.js"></script>

<script src="../js/modernizr.js"></script>

<script src="../js/bootstrap.min.js"></script>
<script src="../js/jquery.uniform.min.js"></script>
<script src="../js/bootstrap-validator/bootstrapValidator.min.js"></script>
<script src="../js/jquery.noty.js"></script>
<script src="../js/common.js"></script>
<script>
    $(function(){

        $('#addForm')
                .bootstrapValidator({
                    feedbackIcons: {
                        valid: 'glyphicon glyphicon-ok',
                        invalid: 'glyphicon glyphicon-remove',
                        validating: 'glyphicon glyphicon-refresh'
                    },
                    fields: {
                        name: {
                            validators: {
                                notEmpty: {
                                    message: '银行卡类型不能为空!'
                                },
                                stringLength: {
                                    min: 5,
                                    max: 12,
                                    message: '登入名长度5到12之间'
                                },
                                remote: {
                                    url: 'checkCardTypeOnly.do',
                                    message: '该类型银行卡已经存在'
                                }
                            }
                        }
                    }
                })
                .on('success.form.bv', function(e) {
                    // Prevent form submission
                    e.preventDefault();

                    var $form = $(e.target);

                    //Use Ajax to submit form data
                    ajaxParam($form.attr('action'), $form.serialize(), 10000, 'POST', 'json', doSuccess);

                    function doSuccess(res) {
                        if(res.status == 100){
                            noty({"text":"新增成功","layout":"top","type":"success"});
                            setTimeout(function () {
                                window.location.href="cardTypeList.web";
                            }, 3000);
                        }else{
                            noty({"text":res.error,"layout":"top","type":"alert","closeButton":"true"});
                        }
                    }

                });
    });
</script>

<!-- end: JavaScript-->

</body>
</html>
